<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\admin\model\Banner;
use app\admin\model\Nav;
use app\admin\model\Corporates;
use think\Env;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {
        $this->success('获取成功', [
            'banner' => $this->banner(),  //轮播
            'nav' => $this->nav(),        //金刚区
        ]);
    }
    /**
     * banner
     *
     */
    public function banner()
    {
        $model = new Banner();
        $data = $model->where(['status' => 1, 'type' => 1])
            ->field('id,title,image')
            ->select();
        foreach ($data as $vo){
            $vo['image'] = config('yuming') . $vo['image'];
//            halt($vo);
        }
        return $data;
    }
    /**
     * 金刚区
     *
     */
    public function nav()
    {
        $model = new Nav();
        $data = $model->where('status' , 1)
            ->field('id,title,image')
            ->select();
        foreach ($data as &$v) {
            $v['image'] = Env::get('app.yuming') . $v['image'];
        }
        return $this->success('获取成功',$data);
    }
}
